$(function(){
	$('#commentTable').on('load-success.bs.table', function(e, data) {
		// 删除确认
		$(".confirm").confirm({
			text : "确认是否删除评论?",
			title : "确认",
			confirm : function(button) {
				deleteComment(button);
			},
			cancel : function(button) {
				// nothing to do
			},
			confirmButton : "确定",
			cancelButton : "取消",
			post : true,
			confirmButtonClass : "btn-danger",
			cancelButtonClass : "btn-default",
			dialogClass : "modal-dialog modal-lg" // Bootstrap classes for
		// large modal
		});
	});
	
	function deleteComment(element) {
		// send get request
		var url = $(element).attr('href');
		$.get(url).done(function(data) {
			// 删除成功，加载数据
			console.log(data.code);
			if (data.code == 0) {
				$('#commentTable').bootstrapTable('refresh');
				alert("删除成功");
			} else {
				alert("删除失败!" + data.message);
			}
		});
		return false;
	}
});